﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.OleDb;
using FredCK.FCKeditorV2;
public partial class Admin_Default2 : System.Web.UI.Page
{
    
 
    protected void Page_Load(object sender, EventArgs e)
    {


        
        

        string deger = Request.QueryString["asayfa"];

        MultiView MultiView1 = (MultiView)LoginView1.FindControl("MultiView1");
         if (deger == "menuler")
        {

            MultiView1.ActiveViewIndex = 0;
        }    

       
       
    }
    protected void Button1_Click(object sender, EventArgs e)
    {


        TextBox Strname = (TextBox)LoginView1.FindControl("TextBox2");
        FileUpload FileUpload1 = (FileUpload)LoginView1.FindControl("FileUpload1");
        TextBox TextBox3 = (TextBox)LoginView1.FindControl("TextBox3");
        FCKeditor FCKeditor1 = (FCKeditor)LoginView1.FindControl("FCKeditor1");
        GrayMatterSoft.GMDatePicker GMDatePicker2 = (GrayMatterSoft.GMDatePicker)LoginView1.FindControl("GMDatePicker2");
        TextBox TextBox5 = (TextBox)LoginView1.FindControl("TextBox5");
        CheckBox CheckBox1 = (CheckBox)LoginView1.FindControl("CheckBox1");
        OleDbConnection con = new OleDbConnection(ConfigurationManager.ConnectionStrings["bgla"].ConnectionString);
        if (con.State == ConnectionState.Closed)
        {
            con.Open();
        }

        OleDbCommand uygula = new OleDbCommand("insert into tblhaberler(StrName,StrImage,StrFrontBody,StrBody,StrDate,StrPart,StrMain) values(?,?,?,?,?,?,?)", con);
        uygula.Parameters.Add("Strname", System.Data.OleDb.OleDbType.VarChar).Value = Strname.Text.ToString();
        string adres = Server.MapPath("../upload");
       
            FileUpload1.SaveAs(adres+ "\\" + FileUpload1.FileName);
            
        string resimgetir;
            resimgetir = "upload";
        
        uygula.Parameters.Add("StrImage", System.Data.OleDb.OleDbType.VarChar).Value = resimgetir + "/" + FileUpload1.FileName.ToString();


        uygula.Parameters.Add("StrFrontBody", System.Data.OleDb.OleDbType.VarChar).Value = TextBox3.Text.ToString();
        uygula.Parameters.Add("StrBody", System.Data.OleDb.OleDbType.VarChar).Value = FCKeditor1.Value.ToString();
        uygula.Parameters.Add("Strdate", System.Data.OleDb.OleDbType.DBDate).Value = GMDatePicker2.Date.ToShortDateString();
        uygula.Parameters.Add("StrPart", System.Data.OleDb.OleDbType.VarChar).Value = TextBox5.Text.ToString();
        uygula.Parameters.Add("StrMain", System.Data.OleDb.OleDbType.Boolean).Value = CheckBox1.Checked.ToString();

        uygula.ExecuteNonQuery();
        con.Close();
        Response.Redirect("adminmain.aspx?asayfa=adminhaber");
    }
    protected void LinkButton2_Click(object sender, EventArgs e)
    {

    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        TextBox Strname = (TextBox)LoginView1.FindControl("TextBox4");

        TextBox TextBox6 = (TextBox)LoginView1.FindControl("TextBox6");
        FCKeditor FCKeditor2 = (FCKeditor)LoginView1.FindControl("FCKeditor2");
        GrayMatterSoft.GMDatePicker GMDatePicker1 = (GrayMatterSoft.GMDatePicker)LoginView1.FindControl("GMDatePicker1");
        
        OleDbConnection con = new OleDbConnection(ConfigurationManager.ConnectionStrings["bgla"].ConnectionString);
        if (con.State == ConnectionState.Closed)
        {
            con.Open();
        }

        OleDbCommand uygula = new OleDbCommand("insert into tblkonular2(konubaslik,kisaacikl,uzunacikl,tarih) values(?,?,?,?)", con);
        uygula.Parameters.Add("konubaslik", System.Data.OleDb.OleDbType.VarChar).Value = Strname.Text.ToString();
        //string adres = Server.MapPath("../upload");

        //FileUpload1.SaveAs(adres + "\\" + FileUpload1.FileName);

        //string resimgetir;
        //resimgetir = "upload";

        //uygula.Parameters.Add("StrImage", System.Data.OleDb.OleDbType.VarChar).Value = resimgetir + "/" + FileUpload1.FileName.ToString();


        uygula.Parameters.Add("kisaacikl", System.Data.OleDb.OleDbType.VarChar).Value = TextBox6.Text.ToString();
        uygula.Parameters.Add("uzunacikl", System.Data.OleDb.OleDbType.VarChar).Value = FCKeditor2.Value.ToString();
        uygula.Parameters.Add("tarih", System.Data.OleDb.OleDbType.DBDate).Value = GMDatePicker1.Date.ToShortDateString();
       
        uygula.ExecuteNonQuery();
        con.Close();
        Response.Redirect("adminmain.aspx?asayfa=adminhaber");     
    }
}
